Class View.DisplayItem

Represents a display item.

Display item is a 3D model of any object available in the level that can be drawn in 2D screen space.

Functions

DisplayItem.SetAmbientLight(color) Set the ambient color for all display items.
DisplayItem.SetCameraPosition(pos, [disableInterpolation]) Set the camera location.
DisplayItem.SetTargetPosition(pos, [disableInterpolation]) Set the camera target location.
DisplayItem.SetFOV([fov], [disableInterpolation]) Set the field of view for all display items.
DisplayItem.GetAmbientLight() Get the ambient color of all the display items.
DisplayItem.GetCameraPosition() Get the camera position.
DisplayItem.GetTargetPosition() Get the position of the camera target.
DisplayItem.GetFOV() Get field of view angle for display items.
DisplayItem.ResetCamera() Reset the camera position, camera target position, and field of view.

Class

DisplayItem(name, objectID, [pos], [rot], [scale], [meshBits]) Create a DisplayItem object.
DisplayItem:SetObjectID(objectID) Change the display item's object ID.
DisplayItem:SetPosition(pos, [disableInterpolation]) Set the display item's position.
DisplayItem:SetRotation(rot, [disableInterpolation]) Set the display item's rotation.
DisplayItem:SetScale(scale, [disableInterpolation]) Set the display item's scale.
DisplayItem:SetColor(color, [disableInterpolation]) Set the display item's color.
DisplayItem:SetMeshBits(meshBits) Set the packed mesh bits for the display item.
DisplayItem:SetMeshVisible(meshIndex, isVisible) Make the specified mesh of a display item visible or invisible.
DisplayItem:SetJointRotation(meshIndex, rot, [disableInterpolation]) Set the display item's joint rotation.
DisplayItem:SetAnim(animNumber) Set the animation number of a display item.
DisplayItem:SetFrame(frameNumber) Set the frame number of a display item's current animation.
DisplayItem:GetObjectID() Retrieve the object ID from a display item.
DisplayItem:GetPosition() Get the display item's position.
DisplayItem:GetRotation() Get the display item's rotation.
DisplayItem:GetScale() Get the display item's scale.
DisplayItem:GetColor() Get the display item's color.
DisplayItem:GetMeshVisible(index) Get the visibility state of a specified mesh in the display item.
DisplayItem:GetJointRotation(meshIndex) Get the display item's joint rotation.
DisplayItem:GetAnim() Get the current animation number of a display item.
DisplayItem:GetFrame() Get the current frame number of the active animation of a display item.
DisplayItem:GetEndFrame() Get the end frame number of the display item's active animation.
DisplayItem:GetBounds() Get the projected 2D bounding box of the display item.
DisplayItem:Draw() Draw the display item in display space for the current frame.


Functions

DisplayItem.SetAmbientLight(color)
Set the ambient color for all display items.

Parameters:

  • color Color New ambient color for all display items.

Usage:

    TEN.View.DisplayItem.SetAmbientLight(TEN.Color(128, 200, 255))
DisplayItem.SetCameraPosition(pos, [disableInterpolation])
Set the camera location. This single camera is used for all display items.

Parameters:

  • pos Vec3 New camera position.
  • disableInterpolation bool Disable interpolation to allow snap movements. Default: false.

Usage:

    TEN.View.DisplayItem.SetCameraPosition(TEN.Vec3(0, 0, 1024))
DisplayItem.SetTargetPosition(pos, [disableInterpolation])
Set the camera target location.

Parameters:

  • pos Vec3 New target camera position.
  • disableInterpolation bool Disable interpolation to allow snap movements. Default: false.

Usage:

    TEN.View.DisplayItem.SetTargetPosition(TEN.Vec3(0, 0, 1024))
DisplayItem.SetFOV([fov], [disableInterpolation])
Set the field of view for all display items.

Parameters:

  • fov float Field of view angle in degrees (clamped to [10, 170]). Default: 80.
  • disableInterpolation bool Disable interpolation to allow snap movements. Default: false.

Usage:

    TEN.View.DisplayItem.SetFOV(80)
DisplayItem.GetAmbientLight()
Get the ambient color of all the display items.

Returns:

    Color Ambient color.

Usage:

    local color = TEN.View.DisplayItem.GetAmbientLight()
DisplayItem.GetCameraPosition()
Get the camera position. This single camera is used for all display items.

Returns:

    Vec3 Camera position for all display items.

Usage:

    local camPos = TEN.View.DisplayItem.GetCameraPosition()
DisplayItem.GetTargetPosition()
Get the position of the camera target.

Returns:

    Vec3 The camera target position for all of the display items.

Usage:

    local targetPosition = TEN.View.DisplayItem.GetTargetPosition()
DisplayItem.GetFOV()
Get field of view angle for display items.

Returns:

    float Current FOV angle in degrees.

Usage:

    local fieldOfView = TEN.View.DisplayItem.GetFOV()
DisplayItem.ResetCamera()
Reset the camera position, camera target position, and field of view.

Usage:

    local targetPosition = TEN.View.DisplayItem.ResetCamera()

Class

Methods for DisplayItem instances.
DisplayItem(name, objectID, [pos], [rot], [scale], [meshBits])
Create a DisplayItem object.

Parameters:

  • name string Lua name of the display item.
  • objectID ObjID Slot object ID.
  • pos Vec3 Position in 3D display space. Default: Vec3(0, 0, 0).
  • rot Rotation Rotation on the XYZ axes. Default: Rotation(0, 0, 0).
  • scale Vec3 Visual scale. Default: Vec3(1, 1, 1).
  • meshBits int Packed meshbits. Optional.

Returns:

    DisplayItem A new DisplayItem object.

Usage:

    local item = TEN.View.DisplayItem("My name", -- name
    TEN.Objects.ObjID.PISTOLS_ITEM, -- object ID) 
DisplayItem:SetObjectID(objectID)
Change the display item's object ID.

Parameters:

  • objectID ObjID New slot object ID.

Usage:

    item:SetObjectID(TEN.Objects.ObjID.BIGMEDI_ITEM)
DisplayItem:SetPosition(pos, [disableInterpolation])
Set the display item's position.

Parameters:

  • pos Vec3 New position.
  • disableInterpolation bool Disable interpolation to allow snap movements. Default: false.

Usage:

    item:SetPosition(TEN.Vec3(0, 200, 1024))
DisplayItem:SetRotation(rot, [disableInterpolation])
Set the display item's rotation.

Parameters:

  • rot Rotation New rotation.
  • disableInterpolation bool Disable interpolation to allow snap movements. Default: false.

Usage:

    item:SetRotation(TEN.Rotation(0, 200, 1024))
DisplayItem:SetScale(scale, [disableInterpolation])
Set the display item's scale.

Parameters:

  • scale Vec3 New scale.
  • disableInterpolation bool Disable interpolation to allow snap movements. Default: false.

Usage:

    item:SetScale(Vec3(2,2,2))
DisplayItem:SetColor(color, [disableInterpolation])
Set the display item's color.

Parameters:

  • color Color New color.
  • disableInterpolation bool Disable interpolation to allow snap color changes. Default: false.

Usage:

    item:SetColor(TEN.Color(128, 200, 255))
DisplayItem:SetMeshBits(meshBits)
Set the packed mesh bits for the display item. Mesh bits represent the visibility of every mesh in a given display item. Can be used in advanced workflows, such as drawing a revolver with or without a lasersight.

Parameters:

  • meshBits int Packed MeshBits to be set.

Usage:

    item:SetMeshBits(3)
DisplayItem:SetMeshVisible(meshIndex, isVisible)
Make the specified mesh of a display item visible or invisible.

Parameters:

  • meshIndex int Mesh index.
  • isVisible bool True to set visible, false to set invisible.

Usage:

    item:SetMeshVisible(1, false)
DisplayItem:SetJointRotation(meshIndex, rot, [disableInterpolation])
Set the display item's joint rotation.

Parameters:

  • meshIndex int Joint index..
  • rot Rotation New rotation.
  • disableInterpolation bool Disables interpolation to allow for snap movements. Default: false.

Usage:

    item:SetJointRotation(1, TEN.Rotation(0, 200, 0))
DisplayItem:SetAnim(animNumber)
Set the animation number of a display item.

Parameters:

  • animNumber int Animation number to set.

Usage:

    item:SetAnim(2)
DisplayItem:SetFrame(frameNumber)
Set the frame number of a display item's current animation. This will set the specified animation to the given frame. The number of frames in an animation can be seen under the heading "End frame" in the WadTool animation editor.

Parameters:

  • frameNumber int Frame number to set.

Usage:

    item:SetFrame(10)
DisplayItem:GetObjectID()
Retrieve the object ID from a display item.

Returns:

    ObjID Slot object ID.

Or

    nil If the display item does not exist.

Usage:

    local objectID = item:GetObjectID()
DisplayItem:GetPosition()
Get the display item's position.

Returns:

    Vec3 Position.

Or

    nil If the display item does not exist.

Usage:

    local objectPosition = item:GetPosition()
DisplayItem:GetRotation()
Get the display item's rotation.

Returns:

    Rotation Rotation.

Or

    nil If the display item does not exist.

Usage:

    local objectRotation = item:GetRotation()
DisplayItem:GetScale()
Get the display item's scale.

Returns:

    float Scale.

Or

    nil If the display item does not exist.

Usage:

    local objectScale = item:GetScale()
DisplayItem:GetColor()
Get the display item's color.

Returns:

    Color Color.

Or

    nil If the display item does not exist.

Usage:

    local objectColor = item:GetColor()
DisplayItem:GetMeshVisible(index)
Get the visibility state of a specified mesh in the display item.

Parameters:

  • index int Index of a mesh.

Returns:

    bool Visibility status.

Or

    bool False if the display item does not exist.

Usage:

    local test = item:GetMeshVisible(1)
    print(test)
DisplayItem:GetJointRotation(meshIndex)
Get the display item's joint rotation.

Parameters:

  • meshIndex int Index of the joint to check.

Returns:

    Rotation Joint rotation.

Or

    nil If the display item does not exist.

Usage:

    local jointRotation = item:GetJointRotation(1)
DisplayItem:GetAnim()
Get the current animation number of a display item. This corresponds to the number shown in the item's animation list in WadTool.

Returns:

    int Active animation number.

Or

    nil If the display item does not exist.

Usage:

    local animNumber = item:GetAnim()
DisplayItem:GetFrame()
Get the current frame number of the active animation of a display item.

Returns:

    int Current frame number of the active animation.

Or

    nil If the display item does not exist.

Usage:

    local frameNumber = item:GetFrame()
DisplayItem:GetEndFrame()
Get the end frame number of the display item's active animation. This is the "End Frame" set in WadTool for the animation.()

Returns:

    int End frame number of the active animation.

Or

    nil If the display item does not exist.

Usage:

    local endFrame = item:GetEndFrame()
DisplayItem:GetBounds()
Get the projected 2D bounding box of the display item. Projects the display item into display space and returns two Vec2 values.

Returns:

  1. Vec2 center Projected center position in display space in percent.
  2. Vec2 size The projected width/height in display space in percent.

Or

    nil If the display item does not exist or has no bounds.

Usage:

    local bounds = item:GetBounds()
    if bounds then
     print("Center: ", bounds[1].x, bounds[1].y)
     print("Size: ", bounds[2].x, bounds[2].y)
    end
DisplayItem:Draw()
Draw the display item in display space for the current frame.

Usage:

    local endFrame = item:Draw()
generated by TEN-LDoc (a fork of LDoc 1.4.6)